﻿//-----------------------------------------------------------------------
// <copyright file="Program.cs" company="DylanBox">
// Copyright (c) DylanBox Corporation. All rights reserved.
// </copyright>
// <summary></summary>
// <reference>
// </reference>
// <author>Dylan</author>
//-----------------------------------------------------------------------
using System;

namespace Structural
{
    /// <summary>
    /// MainApp startup class for Structural
    /// Adapter Design Pattern.
    /// 
    /// Scenario 1: 
    /// old library's api, B.api()   
    /// now, our library, A, want to use this api(),   
    /// 在中间加一个adapter，叫c, 这样A调用c，c调用B； 
    /// 
    /// Scenario 2:
    /// A 调用了 B 的方法b, 但是b方法的参数改了 ， 这样A的代码也得改；
    /// 在中间加一个adapter，叫c, 这样A调用c，c调用B；
    /// 当B的b方法发生参数改变时，不用改A，改c就可以了。 这样可以保证变化性集中到c里面。  
    /// </summary>
    class MainApp
    {
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {           
            ITarget tar = new Adapter();            
            tar.Request();

            // Wait for user
            Console.ReadKey();
        }
    }
    
    /// <summary>
    /// The 'Target' class,
    /// no need change, we can use the old existed interface
    /// Adapters are used to enable objects with different interfaces to communicate with each other.
    /// </summary>
    interface ITarget
    {
        void Request();   
    }
}
